def p(n):
    for d in range(2,int(n**0.5)+1):
        if n%d == 0:
            return False
    return True

pr = [i for i in range(97,1020) if p(i)]

d = {'zero': '0',
     'one': '1',
     'two': '2',
     'three': '3',
     'four': '4',
     'five': '5',
     'six': '6',
     'seven': '7',
     'eight': '8',
     'nine': '9'}

n = input().split()
if len(n) == 3 and all(x in d for x in n):
    s = int(''.join([d[x] for x in n]))
    for i in range(len(pr)):
        if pr[i] > s:
            if abs(s - pr[i]) >= abs(s - pr[i-1]):
                print(pr[i-1])
            else:
                print(pr[i])
            break

else:
    print('Wrong input')




